

/**
 * @author Lukas Koell
 * @author David Medenjak
 * @author Johannes Riedmann
 */
public class IntTree {

    /**
     * Interfaced StringTree.
     */
    StringTree tree;

    /**
     * Constructor to make a StringTree.
     * @param label Value of the root node.
     */
    public IntTree(Integer label) {
        tree = new ReplaceableTree(null, null, null, label.toString());
    }

    /**
     * replaces the label of the node at given position
     * @param position
     * @param subTree
     */
    public void replace(String position, String subTree) {
        ((ReplaceableTree) tree).replace(position, subTree);
    }

    /**
     * searches for a node with given label
     * @param node the label to search for
     * @return null if nothing was found, otherwise string representation 
     *  of the found node
     */
    public String search(Integer node) {
        return tree.search(node.toString());
    }

    /**
     * searches for a node with given label
     * @param node the label to search for
     * @return null if nothing was found, otherwise string representation 
     *  of the found node
     */
    public String search(String node) {
        return tree.search(node);
    }

    /**
     * inserts a node to the tree
     * @param node
     */
    public void add(Integer node) {
        tree.add(node.toString());
    }

    /**
     * checks wether the tree contains a given node
     * @param node
     * @return
     */
    public boolean contains(Integer node) {
        return tree.contains(node.toString());
    }

    /**
     * checks wether the tree contains a given node
     * @param node
     * @return
     */
    public boolean contains(String node) {
        return tree.contains(node);
    }

    @Override
    public String toString() {
        return tree.toString();
    }
}
